import 'package:flutter/cupertino.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';

class MGButton extends StatelessWidget {
  final String title;
  final TextStyle? titleStyle;
  final bool enable;
  final Color? backColor;
  final Color? buttonBackColor;
  final Function()? buttonAction;
  final EdgeInsets? padding;
  final EdgeInsets? margin;

  const MGButton({
    super.key,
    required this.title,
    this.titleStyle,
    this.enable = true,
    this.backColor,
    this.buttonBackColor,
    this.buttonAction,
    this.padding,
    this.margin,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      color: backColor ?? MGColors.whileColor,
      padding: (padding != null) ? padding : null,
      margin: margin,
      constraints: BoxConstraints(
        minWidth: double.infinity,
        minHeight: (padding != null) ? (50.0 + padding!.top + padding!.bottom) : 50.0,
        maxHeight: (padding != null) ? (50.0 + padding!.top + padding!.bottom) : 50.0,
      ),
      child: CupertinoButton(
          color: buttonBackColor ?? MGColors.themeColor,
          disabledColor: (buttonBackColor ?? MGColors.themeColor).withOpacity(0.3),
          borderRadius: const BorderRadius.all(Radius.circular(25)),
          onPressed: enable
              ? () {
                  if (buttonAction != null) {
                    buttonAction!();
                  }
                }
              : null,
          child: Text(title,
              style: titleStyle ??
                  TextStyle(
                    color: enable ? MGColors.text1Color : MGColors.text4Color,
                    fontSize: MGFont.titleFont4,
                    fontWeight: FontWeight.bold,
                  ))),
    );
  }
}
